﻿/******************************************************   
创建者: ljj
创建时间: 2017-10-14
修改:
修改时间: 
功能: 调拨结果明细
 ******************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using com.nm.library.Excels;

namespace CommodityTransferAPI.Export
{
    [Export(typeof(ExcelImport))]
    public class NewGoodsMvJobMessage : ExcelImport
    {
        public override ExcelImportType Type => ExcelImportType.NEWGOODSMVJOBMESSAGE;
        public override Dictionary<string, ImportVerify> DictFields => _dictFields;

        private static readonly Dictionary<string, ImportVerify> _dictFields = new List<ImportVerify> {
            new ImportVerify{ ColumnName="公司代码",FieldName="CompanyID",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="调出仓库代码",FieldName="OutStockCode",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="调出仓库",FieldName="OutStockName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="调入仓库代码",FieldName="InStockCode",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="调入仓库",FieldName="InStockName",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="货号",FieldName="MaterialID",DataType=typeof(string),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,100,true,true)},
            new ImportVerify{ ColumnName="JM",FieldName="JM" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="F",FieldName="F" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="S",FieldName="S",DataType=typeof(int),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="M",FieldName="M",DataType=typeof(int),VerifyFunc =(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="L",FieldName="L",DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true) },
            new ImportVerify{ ColumnName="XL",FieldName="XL",DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true) },
            new ImportVerify{ ColumnName="XXL",FieldName="XXL" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="3XL",FieldName="3XL" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="4XL",FieldName="4XL" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="27",FieldName="27" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="28",FieldName="28" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="29",FieldName="29" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="30",FieldName="30" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="31",FieldName="31" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="32",FieldName="32" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="33",FieldName="33" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="34",FieldName="34" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="35",FieldName="35" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="36",FieldName="36" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="37",FieldName="37" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="38",FieldName="38" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="39",FieldName="39" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="40",FieldName="40" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="41",FieldName="41" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="42",FieldName="42" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="43",FieldName="43" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="44",FieldName="44" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)},
            new ImportVerify{ ColumnName="45",FieldName="45" ,DataType=typeof(int),VerifyFunc=(e,extra)=> ExcelImportHelper.GetCellMsg(e.CellValue,e.ColName,2,false,true)}
            }.ToDictionary(e => e.ColumnName, e => e);

        public override object SaveImportData(DataTable dt, Dictionary<string, object> extraInfo, int userId)
        {
            throw new NotImplementedException();
        }

        public override DataTable GetExportData(string Keys)
        {
            var handler = new MvJobAllMessageHandler();
            var dt = handler.ExportMvJobAllMessage(Keys);
            var regNum = new Regex("^[N]");
            for (var i = 0; i < dt.Columns.Count; i++)
            {
                if (regNum.IsMatch(dt.Columns[i].ColumnName))
                {
                    dt.Columns[i].ColumnName = dt.Columns[i].ColumnName.Substring(1, dt.Columns[i].ColumnName.Length - 1);
                }
            }
            return dt;
        }
    }
}
